<template>
  <header>
    <div class="content-left">
      <el-button type="plain" @click="toggleCollapse">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-menu"></use>
        </svg>
      </el-button>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>
          <span class="bread-title">首页</span>
        </el-breadcrumb-item>
        <el-breadcrumb-item v-if="currentItem">
          <span class="bread-title">{{currentItem.title}}</span>
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="content-right">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img :src="userImg" alt="用户头像" class="avatar">
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item>退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>
<script>
import { mapState } from 'vuex'
export default {
  name: 'CommonHeader',
  data() {
    return {
      userImg: require('assets/img/2.jpeg')
    }
  },
  methods: {
    toggleCollapse() {
      this.$store.commit('toggleCollapse')
    }
  },
  computed: {
    ...mapState([
      "currentItem"
    ])
  }
}
</script>
<style lang="scss" scoped>
  header {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: space-between;
    margin: 0 10px;
  }

  .el-dropdown {
    color: #fff;
  }

  .content-left {
    width: 30%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    .bread-title {
      color: #fff;
    }
    .el-button {
      margin-right: 20px;
    }
  }

  .content-right {
    .avatar {
      width: 48px;
      height: 48px;
      border-radius: 50%;
    }
  }
</style>